
<!--
/**************************************************
* @ iframe/provderquery.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/02/27, owen
*  1) first release
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>

<html>
<head>
<title>供应商浏览</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>


<%
	ArrayList tGSCountry = (ArrayList)request.getAttribute("country");
	ArrayList tGSProvince = (ArrayList)request.getAttribute("province");
	GSProvinceBean tProvinceBean = null;
	String[][] tProvDist = null;
	HashMap tMap2 = new HashMap();
	ArrayList tGSDistinct = (ArrayList)request.getAttribute("district");	
	GSDistrictBean tDistrictBean = null;
	if (tGSProvince != null) {
		for (int i = 0; i < tGSProvince.size(); i++) {
			String tProvcode = ((GSProvinceBean) tGSProvince.get(i)).getGs_province_code();
			if (tGSDistinct != null) {
				tProvDist = new String[tGSDistinct.size()][2];
				for (int j = 0; j < tGSDistinct.size(); j++) {
					tDistrictBean = (GSDistrictBean) tGSDistinct.get(j);
					if (tDistrictBean.getGs_province_code().equals(tProvcode)) {
						tProvDist[j][0] = tDistrictBean.getGs_district_code();
						tProvDist[j][1] = tDistrictBean.getGs_district_name();
						tMap2.put(tProvcode, tProvDist);
					}//end if
				}//end for
			}//end if
		}//end for
	}//end if	
	
	ResultProcess tGSProvider = (ResultProcess)request.getAttribute("provider");
	String[][] tGSCorpProperty = (String[][])request.getAttribute("corpproperty");
	ArrayList tList = new ArrayList();
	String tReQuery = (String)request.getAttribute("requery");
%>
<script language="JavaScript">
	
	var counter;
	function process(val){
		if(val == 'Q' || val == 'Qre'){
				  if (val == 'Qre') {
					<%
					    if(tReQuery!=null && tReQuery.equals("true")){
					        
					%>
						providerviewform.action = "<%= response.encodeURL(request.getContextPath() + "/A180703.do") %>";
                        providerviewform.submit();
                        return true;
			    	<%}%>
		    	} else if (val == 'Q') {
						providerviewform.action = "<%= response.encodeURL(request.getContextPath() + "/A180703.do") %>";
                        providerviewform.submit();
                        return true;
		    	}
		}
	}
	
    function clean(){
      providerviewform.providerName.value ="";
	  providerviewform.provinceCode.value="00";		
	  var listbox = document.getElementById("districtCode");
			listbox.length = 0;
			var option = new Option();
			option.text = "---请选择城市---";
			option.value = "00";			
			listbox.options[listbox.length] = option;	
	  providerviewform.contactid.value="";
	  providerviewform.contactphone.value="";
    }


	function changedistrict(list){
		
  		var val = list;
		if(val=='00'){
			var listbox = document.getElementById("list3");
			listbox.length = 0;
			var option = new Option();
			option.text = "---请选择城市---";
			option.value = "0000";			
			listbox.options[listbox.length] = option;

		}else{
  	<%
  		if(tMap2 !=null){
	 	   	Collection tCollection = tMap2.keySet();
	        Iterator tIterator = tCollection.iterator();
  		       while(tIterator.hasNext()){
  		           String tKey = (String)tIterator.next();
  		           String[][] tDist = (String[][])tMap2.get(tKey);
  	%>
  				if(val == '<%=tKey%>'){
	  				var counter;
	  				var listbox = document.getElementById("list3");
	  				listbox.length = 0;  		  	  								
	<%					
						for(int n=0;n<tDist.length;n++){
						    String distCode = tDist[n][0];
						    String distName = tDist[n][1];
						    if(distCode != null){
	%>				
							var temp1 = '<%=distCode%>';
							var temp2 = '<%=distName%>';
							var option = new Option();
							option.value = temp1;
							option.text = temp2;
							listbox.options[listbox.length] = option;						
	<%
						    }
						}
	%>
  				}
  	<%
  		    }
  		       
  		}
  	%>
  	}	
	}
	
	function returnback(){
		var ary = new Array();
		var indexs = document.getElementsByName("indexs");
		var isSelected = false;
		for(i=0;i<indexs.length;i++){
			if(indexs[i].checked )
				ary = tokenize(indexs[i].value,"|");
		}

		opener.document.getElementById("providerid").value = ary[0];
		opener.document.getElementById("providername").value = ary[1];
		
		window.close();
		return false;
	}
</script>
</head>
<body onload="process('Qre')">

<form name="proform" method="post">

	<input type="hidden" name="gs_provider_id" >	
	<input type="hidden" name="gs_provider_shortname" >	
	<input type="hidden" name="gs_provider_name" >	
	<input type="hidden" name="gs_provider_engname" >	
	<input type="hidden" name="gs_corp_property" >	
	<input type="hidden" name="gs_credit_level" >	
	<input type="hidden" name="gs_corp_addr" >	
	<input type="hidden" name="gs_corp_post" >	
	<input type="hidden" name="gs_principal_id" >	
	<input type="hidden" name="gs_principal_phone" >	
	<input type="hidden" name="gs_contact_id" >	
	<input type="hidden" name="gs_contact_phone" >	
	<input type="hidden" name="gs_reside_country" >	
	<input type="hidden" name="gs_reside_province" >	
	<input type="hidden" name="gs_reside_city" >	
	<input type="hidden" name="gs_work_trade" >	
	<input type="hidden" name="gs_work_manufacture" >	
	<input type="hidden" name="gs_work_scope" >	
	
</form>
<p><br></p>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="98%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="1" class="mtxt_black">&nbsp;</td>
          <td height="30" width="758" class="mtxt_black">供应商管理</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>
<form name="providerviewform" method="get" >

<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				<TR height=20>
					<!-- <TD class="bg_column" align=center>供应商编号</TD>
					<TD align=left class="bg_row_odd">
					<input type="text" name="providerId" value="<%=request.getParameter("providerId")==null? "":request.getParameter("providerId") %>">
					</TD> -->					
					<TD class="bg_column" align=center>供应商名称</TD>
					<TD align=left class="bg_row_odd">
					  <input type="text" name="providerName" value="<%=request.getParameter("providerName")==null? "":request.getParameter("providerName") %>">
					</TD>					
				    <TD class="bg_column" align=center>国家</TD>
					<TD left=right class="bg_row_odd">
						<select name="countryCode">					
						<%
							if(tGSCountry != null && tGSCountry.size() > 0 ){
								for(int i=0; i<tGSCountry.size(); i++){
								    GSCountryBean tGSCountryBean = (GSCountryBean)tGSCountry.get(i);
						%>
								<option value="<%=tGSCountryBean.getGs_en_country_name()%>"><%=tGSCountryBean.getGs_country_name()%></option>
						<%			
								}
							}else{
						%>
								<option value="00">------无------</option>
						<%
							}
						%>
						</select>
					</TD>
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>省份</TD>
					<TD left=right class="bg_row_odd">
						<select name="provinceCode" onChange="changedistrict(this.value)">	
						<option value="00">---请选择省份---</option>				
						<%
							String tProvCode = request.getParameter("provinceCode");
							if(tGSProvince != null && tGSProvince.size() > 0 ){
								for(int i=0; i<tGSProvince.size(); i++){
								    GSProvinceBean tGSProvinceBean = (GSProvinceBean)tGSProvince.get(i);
								    if(tProvCode != null && tProvCode.equals(tGSProvinceBean.getGs_province_code())){
						%>
								<option value="<%=tGSProvinceBean.getGs_province_code()%>" selected><%=tGSProvinceBean.getGs_province_name()%></option>
						<%			        
								    }else{
						%>
								<option value="<%=tGSProvinceBean.getGs_province_code()%>"><%=tGSProvinceBean.getGs_province_name()%></option>
								
						<%			}	
								}
							}
						%>

						</select>
					</TD>
					<TD class="bg_column" align=center>城市</TD>
					<TD left=right class="bg_row_odd" >
					   <select name="districtCode" id="list3">	
						<%
							String tDistrCode = request.getParameter("districtCode");
							if(tProvCode != null){
							    if(!tProvCode.equals("00")){
							    String[][] temp = (String[][])tMap2.get(tProvCode);
							    if(temp != null && temp.length > 0){
								    for(int i=0; i<temp.length; i++){
								   		if(tDistrCode != null && tDistrCode.equals(temp[i][0])){ 
							%>
											<option value="<%=temp[i][0]%>" selected><%=temp[i][1]%></option>																						
							<%		       
								   		}else if(temp[i][0] != null){
							%>
											<option value="<%=temp[i][0]%>"><%=temp[i][1]%></option>
							<%
								   		}
								    }
							    }
								}else{
							%>
							<option value="0000">---请选择城市---</option>
							<%	    
								}
							}else{
						%>
						<option value="0000">---请选择城市---</option>
						<%	    
							}
						%>				
																		
						</select>
					</TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>联系人</TD>
					<TD left=right class="bg_row_odd">
					    <input type="text" name="contactid" value="<%=request.getParameter("contactid")==null? "":request.getParameter("contactid") %>">
					</TD>
					<TD class="bg_column" align=center>联系电话</TD>
					<TD left=right class="bg_row_odd">
					     <input type="text" name="contactphone" value="<%=request.getParameter("contactphone")==null? "":request.getParameter("contactphone") %>">
					</TD>					
				</TR>
                <%
                if(tGSProvider != null) {
                    int totalRecords = 0;
                    if(request.getAttribute("totalRecords")!=null){
                        totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
                    }
                    int defaultPageSize =10;
                    if(request.getAttribute("pageSize")!=null){
                        defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
                    }
                    totalRecords=tGSProvider.getRecordsSize();
                %>          
                <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
                <%tList = tGSProvider.getDisplayRecords(index.intValue(),pageSize.intValue()); %>
                </page:pager>
                <%} %>				
			</table>
		</td>
	</tr>
</table>
</form>
    <p align="center">  
		<input type="button" class="kuang" value="查询" onclick="process('Q')"/>&nbsp;
		<input type="button" class="kuang" value="清空" onclick="clean()"/>&nbsp;		
		<input type="button" class="kuang" value="新增" onclick="newprovider();"/>
    </p>
<%
	
	if(tGSProvider != null){
%>

	<center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
            <form name='pager' method="post">
            <input type=hidden name="ProviderId" >
            	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=98% align=center border=0>
                    <tbody> 
                    <tr class="bg_column" height=20>
                        <td class=top align=middle width="5%"> 
						</td> 

                        <td class=top align=middle> 
                        <div align="center" class="txt_content">供应商名称</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">负责人</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">负责人电话</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">公司性质</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">经营范围</div>
						</td>
                        <!-- <td class=top align=middle> 
                        <div align="center" class="txt_content">信誉等级</div>
						</td>
						-->																																				
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">详细信息</div>
						</td>																	
					</tr>
					<%
						if(tList != null && tList.size() > 0){
						for(int i=0; i<tList.size(); i++){
							String[] tStr = (String[])tList.get(i);
							String tTempStr="";
							if(i%2==0){
								tTempStr="class=\"bg_row_odd\"";
							}else {
								tTempStr="class=\"bg_row_even\"";
							}
					%>
							<tr <%=tTempStr%> height=20>


								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<input type='radio' name='indexs' value='<%=tStr[0] + "|" + tStr[8]%>' onClick='returnback()'>
									</div>
								</td>

								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[1]%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[2]%>
									</div>
								</td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[3]%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[4]%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[5]%>
									</div>
								</td>	
								<!-- 														
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[6]%>
									</div>
								</td>
								 -->																
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<a href="<%= response.encodeURL(request.getContextPath() + "/A400108.do") %>?providerId=<%=tStr[0]%>" target="blank">详细</a>
									</div>
								</td>																	
							</tr> 
							
					<%	
							}
					%>
						  <tr class="bg_column" height=20>
						    <td width="960" height="16" colspan="10" align="right">
									<!--导航条-->
						    		<page:navigator type='text' queryForm='providerviewform'/>
						    </td>
						  
				    <%
						}else{
					%>
							<font color="red">没有符合条件的供应商</font>
					<%
						}
					%>
					</tbody>
				</table>
				</form>					  
			</td>
		</tr>
	</table>
	</center>
	<form action="" name="delform" method="post">	
      <input type=hidden name=ProviderId>		
      <input type=hidden name=providerName>		
      <input type=hidden name=countryCode>		
      <input type=hidden name=provinceCode>		
      <input type=hidden name=districtCode>		
      <input type=hidden name=contactid>		
      <input type=hidden name=contactphone>		
    </form>

<%		
	}
%>

<script langugage='javascript'>
	function newprovider(){
		opener.location="javascript:newprovider()";
		window.close();
	}
</script>

</body>
</html>